#pragma once

#include <Common/b2Draw.h>
#include <SDL2_gfxPrimitives.h>
#include <main/Globals.h>
#include <main/MainConstants.h>

class Box2dDrawDebug : public b2Draw {

	/// Draw a closed polygon provided in CCW order.
	virtual void DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) {
		Sint16* vx = new Sint16[vertexCount];
		Sint16* vy = new Sint16[vertexCount];

		for(size_t i = 0; i < vertexCount; ++i) {
			vx[i] = vertices[i].x * METER_TO_PIXEL;
			vy[i] = vertices[i].y * METER_TO_PIXEL;
		}

		polygonRGBA(Globals::gRenderer, vx, vy, vertexCount, 100, 100, 100, 255);

		delete[] vx;
		delete[] vy;
	}

	/// Draw a solid closed polygon provided in CCW order.
	virtual void DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) {
		Sint16* vx = new Sint16[vertexCount];
		Sint16* vy = new Sint16[vertexCount];

		for(size_t i = 0; i < vertexCount; ++i) {
			vx[i] = vertices[i].x * METER_TO_PIXEL;
			vy[i] = vertices[i].y * METER_TO_PIXEL;
		}

		filledPolygonRGBA(Globals::gRenderer, vx, vy, vertexCount, 100, 100, 100, 255);

		delete[] vx;
		delete[] vy;
	}

	/// Draw a circle.
	virtual void DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color) {}
	
	/// Draw a solid circle.
	virtual void DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color) {}
	
	/// Draw a line segment.
	virtual void DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color) {}

	/// Draw a transform. Choose your own length scale.
	/// @param xf a transform.
	virtual void DrawTransform(const b2Transform& xf) {}

};